package cn.wolf.netty.inboundhandlerandoutboundhandler;


import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * 自定义解码客户端 - 初始化类
 */
public class MyClientInitializer extends ChannelInitializer<SocketChannel> {

    /**
     * 数据出栈编码
     *
     * @param ch 上下文对象
     * @throws Exception 异常
     */
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //添加出栈编码处理器 handler
        pipeline.addLast(new MyByteToLongEncoder());
        //添加入栈解码处理器 handler
        pipeline.addLast(new MyByteToLongDecoder());
        //添加在定义业务处理器 handler
        pipeline.addLast(new MyClientHandler());
    }
}
